<?php declare(strict_types = 1);

namespace Gnway\Ticket\Rest\Response;

use JsonSerializable;

/**
 * Class JsonTemplate
 *
 * @package Gnway\Ticket\Rest\Response
 */
class JsonTemplate implements JsonSerializable
{

  /**
   * Status code
   *
   * @var int
   */
  private int $status;

  /**
   * Response message
   *
   * @var string
   */
  private string $message;

  /**
   * Response data
   *
   * @var array
   */
  private array $result;

  /**
   * JsonTemplate constructor.
   *
   * @param int    $status
   * @param string $message
   * @param array  $result
   */
  public function __construct(int $status = 0, string $message = '', array $result = [])
  {
    $this->status = $status;
    $this->message = $message;
    $this->result = $result;
  }

  /**
   * Status Getter
   *
   * @return int
   */
  public function getStatus(): int
  {
    return $this->status;
  }

  /**
   * Status Setter
   *
   * @param int $status
   */
  public function setStatus(int $status): void
  {
    $this->status = $status;
  }

  /**
   * Message Getter
   *
   * @return string
   */
  public function getMessage(): string
  {
    return $this->message;
  }

  /**
   * Message Setter
   *
   * @param string $message
   */
  public function setMessage(string $message): void
  {
    $this->message = $message;
  }

  /**
   * Result Getter
   *
   * @return array
   */
  public function getResult(): array
  {
    return $this->result;
  }

  /**
   * Result Setter
   *
   * @param array $result
   */
  public function setResult(array $result): void
  {
    $this->result = $result;
  }

  /**
   * Convert to array
   *
   * @return array
   */
  public function toArray(): array
  {
    return ['status' => $this->status, 'message' => $this->message, 'result' => $this->result];
  }

  /**
   * @inheritDoc
   */
  public function jsonSerialize()
  {
    return $this->toArray();
  }
}